<template>
  <div class="detail" v-if="props.showDialog">
    <Dialog
      diaTop="10"
      headerName="详情"
      :showDialog="true"
      @close="close"
      @save="save"
      saveLetter="保存"
      diaWidth="46"
      footerTop="22"
      footerBtm="30"
      :footerShow="false"
    >
      <template #content>
        <div class="content-wrap">
          <div class="title">
            公告标题：<span>{{ itemRow.title }}</span>
          </div>
          <div class="inform">
            通知对象：{{
              groupsList.find((item) => item.value == itemRow.groupid)?.label
            }}
          </div>
          <div class="warning">
            紧急程度：<span>
              {{
                urgencyLevel.find((item) => item.value == itemRow.colorlevel)
                  ?.label || "--"
              }}</span
            >
          </div>
          <div class="time">提交日期：{{ itemRow.publishdate }}</div>
          <div class="content-name">公告内容：</div>
          <div class="content-val" v-html="itemRow.content"></div>
          <div class="word">
            <span>附件：</span>
            <div>
              <div v-for="(item, index) in forList" :key="index" @click="searchFile(item.attachmenturl)" class="wrap">
                <img  src="@/assets/images/word.png" alt="" />{{
                  item.attachmentname
                }}
                <!-- <button >
                  查看文档
                </button> -->
              </div>
            </div>
          </div>
        </div>
      </template>
    </Dialog>
  </div>
</template>
<script setup>
import Dialog from "@/components/DialogCross";
import Upload from "@/components/Upload";
let props = defineProps([
  "showDialog",
  "addOrEditFlag",
  "itemRow",
  "urgencyLevel",
  "groupsList",
]);
let forList = ref([]);
watch(
  () => props.itemRow.attachmentname,
  (newVal) => {
    if (newVal == "") return;
    console.log(newVal, "newVal");
    let name = newVal.split(";");
    let urls = props.itemRow.attachmenturl.split(";");
    for (var i = 0; i < name.length; i++) {
      forList.value.push({ attachmentname: name[i], attachmenturl: urls[i] });
    }
  },
  { deep: true }
);
let emit = defineEmits(["update:showDialog", "save"]);
let params = reactive({});
let formData = reactive({ enterpriseName: "" });
let dataList = ref([]);
let total = ref(1);
let close = () => {
  emit("update:showDialog", false);
};
let save = () => {
  emit("save");
};
let searchFile = (url) => {
  console.log(url, "url");

  let a = document.createElement("a");
  a.href = url;
  a.target = "_blank";
  document.body.appendChild(a);
  a.click();
  document.body.removeChild(a);
};
let getList = () => {};
let handleSearch = () => {};
let options = ref([{ label: "fds,", value: "2" }]);
</script>
<style lang="scss" scoped>
.detail {
  .content-wrap {
    padding-right: 20px;
    padding-left: 20px;
    padding-top: 35px;
    padding-bottom: 20px;
    .title {
      font-family: Source Han Sans CN;
      font-weight: 500;
      font-size: 20px;
      color: #333333;
      line-height: 30px;
      span {
        color: #666;
      }
    }
    .content-name {
      margin-top: 20px;
      font-family: Source Han Sans CN;
      font-weight: 500;
      font-size: 20px;
      color: #333333;
    }
    .content-val {
      margin-top: 15px;
      font-family: Source Han Sans CN;
      font-weight: 400;
      font-size: 20px;
      color: #666666;
      padding: 20px 20px 15px 17px;
      background: #f7f7f7;
      border: 1px dashed #b5b5b5;
      line-height: 40px;
    }
    .time,
    .inform,
    .warning,
    .word {
      margin-top: 20px;
      font-family: Source Han Sans CN;
      font-weight: 500;
      font-size: 20px;
      color: #333333;
      display: flex;

      .wrap {
        display: flex;
        align-items: center;
        margin-top: 20px;
        cursor: pointer;
      }
      .wrap:first-child {
        margin-top: 0px !important;
      }
      img {
        width: 46px;
        margin-right: 10px;

        height: 56px;
      }
      span {
        color: #666;
        flex-shrink: 0;
      }
      button {
        width: 106px;
        height: 35px;
        border-radius: 17px;
        border: 1px solid #0874fa;
        margin-top: 10px;
        font-family: Source Han Sans CN;
        font-weight: 400;
        font-size: 20px;
        color: #0066ff;
        align-self: flex-start;
        margin-right: 20px;
        margin-left: 10px;
      }
    }
  }
  .table-height {
    height: 64.5vh;
  }
  :deep(.el-form-item__label) {
    font-family: Source Han Sans CN;
    font-weight: 500 !important;
    font-size: 20px !important;
    color: #000 !important;
  }
  :deep(.el-input) {
    width: 100%;
    font-family: Source Han Sans CN;
    font-weight: 400;
    font-size: 18px;
    color: #666666 !important;
  }
  :deep(.el-select) {
    width: 100% !important;

    font-family: Source Han Sans CN;
    font-weight: 400;
    font-size: 18px;
    color: #666666 !important;
  }
  :deep(.el-input__inner) {
    font-family: Source Han Sans CN;
    font-weight: 400;
    font-size: 18px;
    color: #333;
  }
  :deep(.el-input) {
    width: 100% !important;
  }
  :deep(.el-input__wrapper, .el-textarea__inner) {
    box-shadow: none;
    font-family: Source Han Sans CN;
    font-weight: 400 !important;
    font-size: 18px !important;
    color: #666666 !important;
    background: #fff !important;
    border-radius: 5px !important;
    border: 1px solid #bfbfbf !important;

    height: 37px !important;
  }
  :deep(.el-input__inner::placeholder) {
    font-family: Source Han Sans CN;
    font-weight: 400;
    font-size: 18px;
    color: #999999;
  }
  :deep(.el-button.el-button--primary) {
    width: 89px;
    margin-top: 6px;
    margin-left: 20px;
    height: 37px;
    background: #0874fa;
    border-radius: 4px;
  }
  .search-done {
    font-family: Source Han Sans CN;
    font-weight: 400;
    font-size: 18px;
  }
  .have-done {
    font-family: Source Han Sans CN;
    font-weight: 400;
    font-size: 18px;
  }
  .pagina {
    :deep(.el-input--default.el-input--suffix) {
      width: 120px !important;
    }
    :deep(.el-input__wrapper) {
      width: 70px !important;
    }
  }
}
</style>
